package com.listen.service.DB;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.listen.common.DateFormatUtil;
import com.listen.common.HttpClientProxy;
import com.listen.common.HttpClientUtil;
import com.listen.common.IPProxyNew;
import com.listen.common.Img2Base64Util;
import com.listen.common.SpecialCharacterHandler;
import com.listen.model.User;
import com.listen.vo.ClassParmsVO;
import com.listen.vo.HeadParmsVO;

/**
 * 三类初培听课
 */
public class AnguanServiceImplNew{
	private static final Logger log = LoggerFactory.getLogger(AnguanServiceImplNew.class);
	private ConcurrentHashMap<String, Object>  resultMap = null;
	private HttpClientProxy instance = new HttpClientProxy();
	private CloseableHttpResponse response = null;
	private CloseableHttpClient httpClient = null;
	private String baseCookie = "";
	private String uid = "";
	private String paramid = "";
	private String __EVENTTARGET = "";
	private String __EVENTARGUMENT = "";
	private String __VIEWSTATE = "";
	private String __VIEWSTATEGENERATOR = "";
	private String proxyInfo = null;
	
	public static void main(String args[]) throws InterruptedException{
		AnguanServiceImplNew anguan = new AnguanServiceImplNew();
		String str = "360111196411161831";
		IPProxyNew proxy = new IPProxyNew(null);
		String[] codes = str.split(",");
		for(String code : codes) {
			//String ipAndPort = proxy.getOneIpAndPort();
			//System.out.println("ipAndPort:"+ipAndPort);
			Thread.sleep(3000);
			for(int i=11;i<=60;i++) {
				User user1 = new User();
				user1.setCode(code);
				user1.setNowNum(i);
				user1.setCreateTm(DateFormatUtil.getDateByStr("20190124"));
				user1.setZy("A2");
				user1.setZyName("新三类初培");
				user1.setPassword("888888");
				user1.setAllNum(60);
				user1.setAddress("http://urdt.cn:8064");
				Map<String,Object> map = anguan.lisetn(user1,null);
				String success = (String) map.get("successFlag");
				if(!"1".equals(success)) {
					break;
				}
			}
		}
	}
	
	//听课业务
	public Map<String,Object> lisetn(User user,String ip){
		//user = this.scopeUser;
		this.proxyInfo = ip;
		ClassParmsVO vo = new ClassParmsVO();
		resultMap = new ConcurrentHashMap<>();
		resultMap.put("successFlag", "0");
		resultMap.put("dayNum", "0");
		resultMap.put("addNum", "0");
		toLoginPage(vo,user);
		return resultMap;
	}
	
	//根据url跳转到具体专业登录页面，并从页面抓取登录所需相关参数
	private void toLoginPage(ClassParmsVO vo,User user){
		String httpUrl = user.getAddress() == null ? "http://urdt.cn:8064" : user.getAddress();
		if("".equals(httpUrl)){
			print("新三类初培专业登录页面url为空");
		}else{
			try {
				response = instance.sendHttpGet(httpClient,httpUrl, proxyInfo);
				int state = response.getStatusLine().getStatusCode();
				if(state == 200){
					HttpEntity entity = response.getEntity();  
					String html = EntityUtils.toString(entity);
				    Document document = Jsoup.parse(html);
				    Element parm2 = document.getElementById("__EVENTVALIDATION");
				    vo.set__eventvalidation(parm2.attr("value"));
				    Element parm3 = document.getElementById("__VIEWSTATE");
				    vo.set__viewstate(parm3.attr("value"));
				    login(vo,user);
				}else{
					print(user.getZyName()+"-"+user.getCode()+"-解析页面参数失败");
				}
			} catch (Exception e) {
				printError(user.getZyName()+"-"+user.getCode()+"-解析页面参数异常",e);
			} finally{
				instance.closeResource(response,httpClient);
			}
		}
	}
	
	//根据用户名、密码、专业类型，登录听课网页
	private void login(ClassParmsVO vo,User user) throws Exception{
		Map<String, String> maps = new HashMap<String, String>();
        maps.put("__VIEWSTATE", vo.get__viewstate()); 
        maps.put("__EVENTVALIDATION",vo.get__eventvalidation()); 
        maps.put("txtUserName",user.getCode());
        maps.put("txtPwd",user.getPassword());
        maps.put("ddlType", "2");//学员登录 
        maps.put("btnLogin", "");
        maps.put("txtLoginName", ""); 
        maps.put("txtDM", "");
        maps.put("txtFR", ""); 
        maps.put("zhjg", "");
        maps.put("zhfr", "");
        try {
        	HeadParmsVO head = new HeadParmsVO();
	        head.setAccept("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
			head.setContentType("application/x-www-form-urlencoded");
			response = instance.sendHttpPost(httpClient, head, user.getAddress(), maps, proxyInfo);
        	int state = response.getStatusLine().getStatusCode();
        	vo.setLoginState(state);
        	if(state==302 || state==200){
        		Header[] hearders = response.getHeaders("Set-Cookie");
        		if(hearders != null && hearders.length > 0) {
        			if(hearders.length == 3) {
        				String sessionIds = hearders[0].getValue();
                		String sessionId = sessionIds.substring(0, sessionIds.indexOf(";") + 1);
                		vo.setSessionId(sessionId);
                		String userIdCookie = hearders[1].getValue();
                		String userid = userIdCookie.substring(0, userIdCookie.indexOf(";") + 1);
                		vo.setUserid(userid);
                		String infoCookies = hearders[2].getValue();
                		String info = infoCookies.substring(0, infoCookies.indexOf(";") + 1);
                		this.uid = userid.substring(userid.indexOf("=")+1,userid.length()-1);
                		//System.out.println(uid);
                		this.baseCookie = sessionId + userid + info;
                		vo.setInfo(info);
        			}
        			if(hearders.length == 4) {
        				String sessionIds = hearders[1].getValue();
                		String sessionId = sessionIds.substring(0, sessionIds.indexOf(";") + 1);
                		vo.setSessionId(sessionId);
                		String userIdCookie = hearders[2].getValue();
                		String userid = userIdCookie.substring(0, userIdCookie.indexOf(";") + 1);
                		vo.setUserid(userid);
                		String infoCookies = hearders[3].getValue();
                		String info = infoCookies.substring(0, infoCookies.indexOf(";") + 1);
                		this.uid = userid.substring(userid.indexOf("=")+1,userid.length()-1);
                		//System.out.println(uid);
                		this.baseCookie = sessionId + userid + info;
                		vo.setInfo(info);
        			}
        		}
        		shipinSection(vo,user);
        	}else{
        		print(user.getZyName()+"-"+user.getCode()+"-登录失败--->"+state);
        	}
		} catch (Exception e) {
			printError(user.getZyName()+"-"+user.getCode()+"-登录异常--->",e);
		}finally{
			instance.closeResource(response,httpClient);
		}
	}

	private void shipinSection(ClassParmsVO vo,User user) {
		String zyName = user.getZyName();
		int i = user.getNowNum();
		String shipinSection_url = user.getAddress() + "/StudentClass/shipinSection.aspx";
		user.setReferer(shipinSection_url);
		String cookie = this.baseCookie;
		HeadParmsVO heads = new HeadParmsVO();
		heads.setAccept("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
		heads.setCookie(cookie);
		heads.setUpgradeInsecureRequests("1");
		try {
			response = instance.sendHttpGet(httpClient,heads, shipinSection_url,proxyInfo);
			int state = response.getStatusLine().getStatusCode();
			//Thread.sleep(1000);
			if(state == 200){
				//print(zyName+"-"+ user.getCode() +" 第"+i +"个视频,shipinSection-->方法请求成功:"+state);
				HttpEntity entity = response.getEntity();
				String html = EntityUtils.toString(entity);
				Document document = Jsoup.parse(html);
				
				Element parm3 = document.getElementById("__VIEWSTATE");
				this.__VIEWSTATE = parm3.attr("value");
				
				Element parm4 = document.getElementById("__VIEWSTATEGENERATOR");
				this.__VIEWSTATEGENERATOR = parm4.attr("value");
				checkCanWatch(vo,user);
			}else{
				print(zyName+"-"+ user.getCode() +" 第"+i +"个视频,shipinSection-->方法请求失败:"+state);
			}
		}catch(Exception e) {
			printError(user.getZyName()+"-"+user.getCode()+"-shipinSection-->方法请求异常:",e);
			logout(vo,user);
		}finally {
			HttpClientUtil.getInstance().closeResource(response);
		}
	}
	
	//开始学习
	private void checkCanWatch(ClassParmsVO vo,User user) {
		int i = user.getNowNum();
		this.paramid = i < 10 ? "0000"+i : "000"+i;
		String params = "{Vcode:\"" + paramid + "\"}";
		String checkCanWatch_url = user.getAddress() + "/StudentClass/shipinSection.aspx/CheckCanWatch";
		
		HeadParmsVO heads = new HeadParmsVO();
		heads.setCookie(this.baseCookie);
		heads.setReferer(user.getReferer());
	    heads.setAccept("application/json, text/javascript, */*; q=0.01");
	    heads.setAcceptEncoding("gzip, deflate");
	    heads.setAcceptLanguage("zh-CN,zh;q=0.9");
	    heads.setContentType("application/json; charset=UTF-8");
	    heads.setxRequestedWith("XMLHttpRequest");
    	heads.setUpgradeInsecureRequests("1");
    	heads.setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36");
    	
		user.setReferer(checkCanWatch_url);//设置referer
		try {
			//Thread.sleep(1000);
			response = instance.sendHttpPost(httpClient, heads, checkCanWatch_url, params,proxyInfo);
			int state = response.getStatusLine().getStatusCode();
			//String resMsg = EntityUtils.toString(response.getEntity(), "UTF-8");
			//JSONObject json = JSONObject.fromObject(resMsg);
			//String result = (String) json.get("d");
			//System.out.println(result);
			if(state == 200){
				//print(user.getZyName()+"-"+ user.getCode() +" 第"+i +"个视频,-checkCanWatch-->请求成功:"+state);
				shipinSectionPost(vo,user);
			}else{
				print(user.getZyName()+"-"+ user.getCode() +" 第"+i +"个视频,-checkCanWatch-->请求失败:"+state);
			}
		} catch (Exception e) {
			printError(user.getZyName()+"-"+user.getCode()+"-checkCanWatch-->请求异常:",e);
			logout(vo,user);
		}finally {
			HttpClientUtil.getInstance().closeResource(response);
		}
	}
	
	public void shipinSectionPost(ClassParmsVO vo,User user) {
		String shipinSectionPost_url = user.getAddress() + "/StudentClass/shipinSection.aspx";
		
		HeadParmsVO heads = new HeadParmsVO();
	    heads.setAccept("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
	    heads.setAcceptEncoding("gzip, deflate");
	    heads.setAcceptLanguage("zh-CN,zh;q=0.9");
	    heads.setContentType("application/x-www-form-urlencoded");
	    heads.setxRequestedWith("XMLHttpRequest");
	    heads.setCookie(this.baseCookie);
    	heads.setReferer(user.getReferer());
    	heads.setUpgradeInsecureRequests("1");
    	heads.setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36");
    	
    	int classNo = user.getNowNum();
    	Map<String, String> maps = new HashMap<String, String>();
    	maps.put("__EVENTTARGET", this.__EVENTTARGET);
		maps.put("__EVENTARGUMENT", this.__EVENTARGUMENT);
        maps.put("__VIEWSTATE", this.__VIEWSTATE); 
        maps.put("__VIEWSTATEGENERATOR",this.__VIEWSTATEGENERATOR);
        maps.put("dr1","-1");
        
        user.setReferer(shipinSectionPost_url);
        for(int k=0;k<10;k++) {
        	String key = "rep1$ctl0"+ k +"$hdOrders";
        	maps.put(key, "0");
    		if(classNo%10 != 0) {
    			if((k+1)==(classNo%10)) {
    				maps.put("rep1$ctl0"+k+"$Button1", "进入听课");
    			}
    		}else {
    			if(k == 9) {
    				maps.put("rep1$ctl09$Button1", "进入听课");
    			}
    		}
        }
        try {
        	//Thread.sleep(1000);
        	response = instance.sendHttpPost(httpClient, heads, shipinSectionPost_url, maps, proxyInfo);
        	int status = response.getStatusLine().getStatusCode();
    		if(status == 200) {
    			//print(user.getZyName()+"-"+user.getCode() +"-第"+classNo+"个视频-shipinSection-post--> 请求成功"+status);
    			this.watchVideo(vo,user);
    		}else {
    			print(user.getZyName()+"-"+user.getCode() +"-第"+classNo+"个视频-shipinSection-post--> 请求成功"+status);
    		}
		} catch (Exception e) {
			print(user.getZyName()+"-"+user.getCode() +"-第"+ classNo +"个视频-shipinSection-post--> 请求异常"+e);
		}finally {
			instance.closeResource(response, httpClient);
		}
	}
	
	public void watchVideo(ClassParmsVO vo,User user){
		int nowNum = user.getNowNum();
		
		String watchVideo_url = user.getAddress() +"/StudentClass/WatchVideo.aspx?ids="+this.paramid;
		//System.out.println("watchVideo_url="+watchVideo_url);
		HeadParmsVO heads = new HeadParmsVO();
	    heads.setAccept("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
	    heads.setAcceptEncoding("gzip, deflate");
	    heads.setAcceptLanguage("zh-CN,zh;q=0.9");
	    heads.setCookie(this.baseCookie);
    	heads.setReferer(user.getReferer());
    	heads.setUpgradeInsecureRequests("1");
    	heads.setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36");
    	
    	user.setReferer(watchVideo_url);
    	try {
    		//Thread.sleep(1000);
    		response = instance.sendHttpGet(httpClient, heads, watchVideo_url, proxyInfo);
    		int status = response.getStatusLine().getStatusCode();
    		if(status == 200) {
				user.setReferer(watchVideo_url);
				//print(user.getZyName()+"-"+user.getCode() +"-第"+ nowNum +"个视频-watchVideo--> 请求成功"+status);
				webForm(vo,user);
    		}else {
    			print(user.getZyName()+"-"+user.getCode() +"-第"+ nowNum +"个视频-watchVideo--> 请求失败"+status);
    		}
		} catch (Exception e) {
			print(user.getZyName()+"-"+user.getCode() +"-第"+ nowNum +"个视频-watchVideo--> 请求异常"+e);
		}finally {
			instance.closeResource(response, httpClient);
		}
	}
	
	//人脸验证
	private void webForm(ClassParmsVO vo,User user){
		Map<String, String> maps = new HashMap<String, String>();
		String os = System.getProperty("os.name");
		String path = "";
		Date d = user.getCreateTm() == null ? new Date() : user.getCreateTm();
		String dataStr = DateFormatUtil.getDateStr(d, "yyyyMMdd");
		if(os.toLowerCase().startsWith("win")){  
			path = "D:\\photos\\"+dataStr+"\\";
		}else {
			path = "/home/listen/photos/"+dataStr+"/";
		}
		int i = user.getNowNum();
		String code = user.getCode();
		String zyName = user.getZyName();
		String webForm_url = user.getAddress() + "/StudentClass/WebForm1.aspx";
        try {
        	Thread.sleep(5000);
        	String image = "data:image/png;base64,"+Img2Base64Util.getImgStr(path + code +".png");
			String referer = user.getReferer();
			String url = SpecialCharacterHandler.replaceAll(referer);
			maps.put("type", "data"); 
	        maps.put("image",image);
        	//st构建
			String Start = DateFormatUtil.getDateAnyMinuteBeforeStr(0);
			Start = Start.replaceAll(" ", "+").replaceAll(":", "%3a");
			String st = "0001/1/1%200%3A00%3A00";
			String cookies = this.baseCookie + "id="+paramid+";totaltime=2326; url="+url+"; checkUid="+uid+"; Start="+ Start +";st="+st+";nowtime=28";
			//System.out.println("webForm:"+cookies);
			HeadParmsVO heads = new HeadParmsVO();
			heads.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
			heads.setAcceptEncoding("gzip, deflate");
			heads.setxRequestedWith("XMLHttpRequest");
			heads.setCookie(cookies);
			heads.setReferer(referer);
			
			user.setReferer(webForm_url);
			response = instance.sendHttpPost(httpClient, heads, webForm_url, maps, proxyInfo);
        	int state = response.getStatusLine().getStatusCode();
        	if(state == 200){
        		String resMsg = EntityUtils.toString(response.getEntity(), "UTF-8");
				print(zyName+"-"+ code +" 第"+i +"个视频人脸识别成功 "+resMsg);
				listenVideos(vo,user);
			}else{
				String resMsg = EntityUtils.toString(response.getEntity(), "UTF-8");
				print(zyName+"-"+ code +" 第"+i +"个视频人脸识别失败"+resMsg);
			}
		} catch (Exception e) {
			printError(user.getZyName()+"-"+user.getCode()+"-个视频人脸识别异常--->",e);
			logout(vo,user);
		}finally{
			HttpClientUtil.getInstance().closeResource(response);
		}
	}
	
	//网络初次培训平台听课
	private boolean listenVideos(ClassParmsVO vo,User user){
		String code = user.getCode();
		int i = user.getNowNum();
		String name = user.getZyName();
		boolean b = true;
		try {
			//Thread.sleep(1000);
			String rvCodeJson = "{\"RVCode\":\"" + this.paramid + "\"}";
			int number = (int)(40+Math.random()*(60-40+1));//40-60之间的数
			String Start = DateFormatUtil.getDateAnyMinuteBeforeStr(number);
			Start = Start.replaceAll(" ", "+").replaceAll(":", "%3a");
			String st = "0001/1/1%200%3A00%3A00";
			String referer = user.getReferer();
			String url = SpecialCharacterHandler.replaceAll(referer);
			
			String cookies = this.baseCookie + "id="+paramid+";totaltime=2326; url="+url+"; checkUid="+uid+"; Start="+ Start +";st="+st+";nowtime=28";
			String updateUrl = user.getAddress() + "/EntpClass/Xtyl1.ashx?classid="+i+"&uid="+uid;
			HeadParmsVO head = new HeadParmsVO();
			head.setContentType("application/json; charset=UTF-8");
			head.setCookie(cookies);
			head.setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36");
			head.setxRequestedWith("XMLHttpRequest");
			
			response = instance.sendHttpPost(httpClient, head, updateUrl, rvCodeJson, proxyInfo);
			int state = response.getStatusLine().getStatusCode();
			String msg = EntityUtils.toString(response.getEntity(), "UTF-8");
			if(state == 200){
				print(name+"-"+ code +" 第"+ i +"个视频听课"+msg);
				user.setIp(this.proxyInfo);
				resultMap.put("successFlag", "1");
				if("进度更新完毕，请看下个视频".equals(msg) || "课程全部看完，可以进行考试".equals(msg)){
					resultMap.put("dayNum", "1");
					resultMap.put("addNum", "1");
				}else if("本视频播放完毕".equals(msg)||"".equals(msg)){
					resultMap.put("addNum", "1");
				}else {
					log.info("三类A初培听课异常-->"+msg);
				}
				if(user.getAllNum()==i)
					user.setStatus(3);
			}else{
				print(name+"-"+ code +"-第"+i +"个视频"+msg + "state="+state);
			}
			Thread.sleep(5000);
		} catch (Exception e) {
			printError(name+"-"+ code +"-第"+i +"个视频播放异常",e);
		}finally{
			logout(vo,user);
			instance.closeResource(response,httpClient);
		}
		return b;
	}	
	
	//网络初次培训平台听课
	/*private boolean listenVideos1(ClassParmsVO vo,User user){
		CloseableHttpResponse response = null;
		String userid = vo.getUserid();
		String sessionid = vo.getSessionId();
		String info = vo.getInfo();
		
		String code = user.getCode();
		String zyName = user.getZyName();
		int i = user.getNowNum();
		String checkUid = userid.split("=")[1];
		boolean b = true;
		try {
			String rvCode = i < 10 ? "0000" + i : "000" + i;
			String rvCodeJson = "{\"RVCode\":\"" + rvCode + "\"}";
			//st构建
			String date = DateFormatUtil.getDateStr(new Date());
			String day = date.split(" ")[0];
			String hms = date.split(" ")[1];//时分秒
			String st = day + "%20" + URLEncoder.encode(hms,"utf-8");
			String cookies = sessionid + userid + info + " totaltime=2282; checkUid="+ checkUid + " st="+ st +"; nowtime=2281";
			//String updateUrl = user.getAddress() + "/StudentClass/WatchVideo.aspx/UpdateStudyType";
			String updateUrl = vo.getLoginurl() + "/EntpClass/Xtyl1.ashx?classid="+i+"&uid="+checkUid;
			HttpPost httpPost = new HttpPost(updateUrl);// 创建httpPost
			httpPost.setHeader("X-Requested-With","XMLHttpRequest");
			httpPost.setHeader("Content-Type","application/json; charset=UTF-8");
			httpPost.setHeader("Accept","application/json");
			httpPost.setHeader("Cookie", cookies);
			response = HttpClientUtil.getInstance().sendHttpPost(httpPost, rvCodeJson);
			int state = response.getStatusLine().getStatusCode();
			String msg = EntityUtils.toString(response.getEntity(), "UTF-8");
        	//String msg = (String) JSONObject.fromObject(entityStr).get("d");
			if(state == 200){
				print(zyName+"-"+ code +" 第"+i +"个视频"+msg);
				resultMap.put("successFlag", "1");
				if("进度更新完毕，请看下个视频".equals(msg) || "课程全部看完，可以进行考试".equals(msg)){
					resultMap.put("dayNum", "1");
					resultMap.put("addNum", "1");
				}else if("本视频播放完毕".equals(msg)){
					resultMap.put("addNum", "1");
				}
				if(user.getAllNum()==i)
					user.setStatus(3);
			}else{
				print(zyName+"-"+ code +"-第"+i +"个视频"+msg + "state="+state);
			}
			Thread.sleep(1000);
		} catch (Exception e) {
			printError(zyName+"-"+ code +"-第"+i +"个视频播放异常",e);
		}finally{
			logout(vo,user);
			HttpClientUtil.getInstance().closeResource(response);
		}
		
		return b;
	}*/
	
	//退出登录
	private void logout(ClassParmsVO vo,User user){
		String code = user.getCode();
		String zyName = user.getZyName();
		String userid = vo.getUserid();
		String sessionid = vo.getSessionId();
		String info = vo.getInfo();
		try {
			String path = user.getAddress() + "/Public/Logout.aspx";
			String cookie = sessionid + userid + info + " totaltime=2281; checkUid=38060; nowtime=2281";
			//httpGet = new HttpGet(path);
			//httpGet.setHeader("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
			//httpGet.setHeader("Cookie", cookie);
			//response = HttpClientUtil.getInstance().sendHttpGet(httpGet);
			HeadParmsVO heads = new HeadParmsVO();
			heads.setAccept("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
			heads.setCookie(cookie);
			response = instance.sendHttpGet(httpClient, heads, path, proxyInfo);
			int state = response.getStatusLine().getStatusCode();
			if(state == 200 || state == 302){
				//print(zyName+"-"+ code +"-退出登录成功!");
			}else{
				print(zyName+"-"+ code +"-退出登录失败!");
			}
		} catch (Exception e) {
			printError(zyName+"-"+ code +"-退出登录失败--->",e);
		}finally{
			instance.closeResource(response,httpClient);
		}
	}
	
	private void print(String msg){
		resultMap.put("msg", msg);
		log.info(msg);
	}
	
	private void printError(String msg,Exception e){
		msg = msg + e.getMessage();
		resultMap.put("msg", msg);
		log.info(msg,e);
	}
}
